<!DOCTYPE html>
<html>
<head>
    <title>ddd</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <script language="JavaScript" src="../js/jquery-1.4.2.js"></script>
</head>
<body>
<form>
    <input type="checkbox" name="hobby" value="篮球"/>篮球
    <input type="checkbox" name="hobby" value="足球"/>足球
    <input type="checkbox" name="hobby" value="排球"/>排球
    <input type="checkbox" name="hobby" value="乒乓球"/>乒乓球
    <input type="button" name="b1" id="b1" value="选中的个数"/>

</form>
<script type="text/javascript">
    $().ready(function(){
        $("#b1").click(function(){
            alert($("input:checkbox:checked").length);
        });
    });

</script>
</body>
</html>